//
//  AppDelegate.swift
//  SinaWeibo
//
//  Created by AenyMo on 16/3/30.
//  Copyright © 2016年 AenyMo. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?


    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
        
        //初始化window
        window = UIWindow(frame: UIScreen.mainScreen().bounds)
        window?.backgroundColor = UIColor.whiteColor()
        window?.makeKeyAndVisible()
        
        //设置默认根控制器(主控制器,还是行特性控制器)
        window?.rootViewController = SWMainViewController()
        
        //设置根控制器    根据监听到的通知显示不同的控制器
        //name: 通知名称   object: 哪一个对象发出的通知(nil为所有对象)
        //queue: 队列(后面闭包执行的线程) nil为主线程    监听到通知后的操作
        NSNotificationCenter.defaultCenter().addObserverForName(SWrootViewControllerNotification, object: nil, queue: nil) { [weak self] (notification) in

            //设置根控制器
            self!.window?.rootViewController = notification.userInfo == nil ? SWMainViewController() : SWWellcomeViewController()
        }
        
        //设置主题
        setupThemeColor()
        
        return true
    }
    
    
    //设置主题颜色
    private func setupThemeColor() {
        
        UINavigationBar.appearance().tintColor = themeColor
        UITabBar.appearance().tintColor = themeColor
    }

    

}

